<template>
  <div class="order-detail-page" v-if="order">
    <!-- 操作栏 -->
    <DetailAction :order="order" />
    <!-- 步骤条 组件xtx-steps.vue-->
    <!-- 步骤条-->
    <DetailSteps :order="order" />
    <!-- 物流 -->
    <Suspense>
      <template #default>
        <DetailLogistics
          v-if="[3, 4, 5].includes(order.orderState)"
          :order="order"
        />
      </template>
      <template #fallback>
        <div class="loading">loading...</div>
      </template>
    </Suspense>
    <!-- 订单商品信息 -->
    <DetailInfo :order="order"></DetailInfo>
  </div>
</template>
<script>
import { ref } from "vue";
import DetailAction from "./components/detail-action";
import { findOrderDetail } from "@/api/order";
import { useRoute } from "vue-router";
import DetailSteps from "./components/detail-steps.vue";
import DetailLogistics from "./components/detail-logistics.vue";
import DetailInfo from "./components/detail-info.vue";
export default {
  name: "OrderDetailPage",
  components: { DetailAction, DetailSteps, DetailLogistics, DetailInfo },
  setup() {
    const route = useRoute();
    const order = ref(null);
    findOrderDetail(route.params.id).then((data) => {
      order.value = data.result;
    });
    return { order };
  },
};
</script>
<style scoped lang="less">
.order-detail-page {
  background: #fff;
}
</style>